/*
 * Created on 19.09.2006 by leck
 *
 */
package de.devisnik.eidle.flashlight;


public class Square implements IShape {
    
    private final int itsRadius;

    public Square(int radius) {
        itsRadius = radius;
    }
    
    public int[] getPointArray(int centerX, int centerY) {
        return square(itsRadius, centerX, centerY);
    }

    private int[] square(int r, int offsetX, int offsetY) {
      int[] square = new int[8];
      int x = (int) Math.sqrt(r*r/2);
      square[0] = offsetX-x;
      square[1] = offsetY-x;
      square[2] = offsetX+x;
      square[3] = offsetY-x;
      square[4] = offsetX+x;
      square[5] = offsetY+x;
      square[6] = offsetX-x;
      square[7] = offsetY+x;
      return square;
  }

}
